package com.hejr.service.impl;

import com.hejr.service.IIndexService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author: hejr
 * @desc:
 * @date: 2019/4/16 16:06
 */
@Service
@Slf4j
public class IndexServiceImpl implements IIndexService {


    @Async
    @Override
    public void updateVipInfo(String userId) {
        log.info("【查询VIP用户信息开始】，参数：[userId：{}]", userId);
        try {
            Thread.sleep(5 * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("【查询VIP用户信息结束】，参数：[userId：{}]", userId);
    }

    @Async
    @Override
    public void updateUserMoney(String userId) {
        log.info("【查询用户投资金额开始】，参数：[userId：{}]", userId);
        try {
            Thread.sleep(10 * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("【查询用户投资金额开始】，参数：[userId：{}]", userId);
    }

    @Async
    @Override
    public void updateUserInfo(String userId) {
        log.info("【更新用户信息开始】，参数：[userId：{}]", userId);
        try {
            updateVipInfo(userId);
            updateUserMoney(userId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("【更新用户信息结束】，参数：[userId：{}]", userId);
    }
}
